﻿using EntityFrameworkCore.Comment;
using Microsoft.EntityFrameworkCore;
using System;

namespace Test.Database
{
    public class SchoolDbContext : DbContext
    {
        public const string ConnectString = "server=localhost;user=root;pwd=123456;database=test_efc;";

        public SchoolDbContext()
        {
        }

        bool _onDbContextOptions = false;

        public SchoolDbContext(DbContextOptions options) : base(options)
        {
            _onDbContextOptions = true;
            Console.WriteLine("OnDbContextOptions");
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (_onDbContextOptions)
                return;
            Console.WriteLine("OnConfiguring");
            optionsBuilder.UseMySql(ConnectString);
        }



        [Comment("Comment of Teachers")]
        public DbSet<Teacher> Teachers { get; set; }

        [Comment("Comment of Students")]
        public DbSet<Student> Students { get; set; }
    }
}
